<!DOCTYPE html>
<html lang="zh">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title>注册页面</title>
  <style>
    body {
      font-family: Arial, sans-serif;
      background-color: #f2f2f2;
    }

    .container {
      max-width: 400px;
      margin: 0 auto;
      padding: 20px;
      background-color: #fff;
      border: 1px solid #ccc;
      border-radius: 5px;
      box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    }

    h2 {
      text-align: center;
    }

    .form-group {
      margin-bottom: 15px;
    }

    .form-group label {
      display: block;
      font-weight: bold;
      margin-bottom: 5px;
    }

    .form-group input {
      width: 100%;
      padding: 8px;
      border: 1px solid #ccc;
      border-radius: 3px;
    }

    .form-group button {
      width: 100%;
      padding: 8px;
      background-color: #4CAF50;
      color: #fff;
      border: none;
      border-radius: 3px;
      cursor: pointer;
    }
  </style>
</head>
<body>
  <div class="container">
    <h2>注册</h2>

      <div class="form-group">
        <label for="username">用户名：</label>
        <input type="text" id="username" name="username" required>
      </div>

      <div class="form-group">
        <label for="password">密码：</label>
        <input type="password" id="password" name="password" required>
      </div>
      <div class="form-group">
        <button onclick="zc()">注册</button>
      </div>

  </div>
  <script src="axios.min.js"></script>
  <script>



        function zc(){

          var username = document.getElementById("username");
          var password = document.getElementById("password");
          var name = username.value;
          var pass = password.value;
          var url = "http://localhost:8080/system/person/register";
          const data = {
            userName: name,
            passWord: pass
          }

          axios.post(url,data,{
            Headers: {
              'Content-Type':'application/json'
            }
          }).then(response => {
            if(response.data.code == 200){
               alert("注册成功");
               window.location.href = "login.html"
            }else{
               alert(response.data.message)
            }


          })

        }


  </script>
</body>
</html>
